﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace jQube.Web.UI
{
    public class ScriptReference
    {
        public string Assembly { get; set; }

        public string Type { get; set; }

        public string ResourceName { get; set; }

        public string Path { get; set; }

        internal string GetPathRelativeToPage(IPage page)
        {
            return page.ResolveClientUrl(this.Path);
        }

        internal string GetWebResourceUrl(IPage page)
        {
            Assembly assembly = System.Reflection.Assembly.Load(this.Assembly);
            return page.ClientScript.GetWebResourceUrl(assembly.GetType(this.Type, true), this.ResourceName);
        }
    }
}
